from django.db import models
from django.contrib.auth.models import AbstractUser
from apps.common.base.models import BaseModel
from apps.system.role.models import Role
from apps.system.rank.models import Rank
from apps.system.team.models import Team
from apps.system.identity.models import Identity
from apps.common.base.models import CustomManager

class UserModel(AbstractUser, BaseModel):
    """扩展Django自带的User模型"""
    gender = (
        ("M", "男"),
        ("W", "女"),
    )
    checkStatus = (
        ("PASS", "通过"),
        ("REFUSE", "拒绝"),
        ("CHECKING", "审核中"),
    )

    objects = CustomManager()

    role=models.ForeignKey(Role, related_name='role_user', to_field='key', on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False)
    parent=models.ForeignKey('UserModel', related_name='parent_user', on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False)

    code = models.CharField("编码", max_length=200, blank=True, null=True, default='')
    phone = models.CharField("手机号", max_length=200, blank=True, null=True, default='')
    nickname = models.CharField("昵称", max_length=200, blank=True, null=True, default='')
    realname = models.CharField("姓名", max_length=200, blank=True, null=True, default='')
    openid = models.CharField("openid", max_length=200, blank=True, null=True, default='')

    idCard = models.CharField("身份证号码", max_length=200, blank=True, default='')
    avatarUrl = models.CharField("头像", max_length=200, blank=True)
    gender = models.CharField("性别", max_length=200, choices=gender, blank=True, default='')
    age = models.CharField("年龄", max_length=200, blank=True, default='')
    height = models.CharField("身高", max_length=200, blank=True, default='')
    weight = models.CharField("体重", max_length=200, blank=True, default='')
    weixin = models.CharField("微信", max_length=200, blank=True, default='')
    birthday = models.DateTimeField('出生日期', blank=True, null=True)
    email = models.CharField("电子邮箱", max_length=200, blank=True, default='')
    city = models.CharField("现居地", max_length=200, blank=True, default='')
    job = models.CharField("职业", max_length=200, blank=True, default='')
    status = models.IntegerField("状态", default=1)
    isRobot = models.BooleanField('是否是机器人', default=0)

    class Meta:
        verbose_name = '用户模型'
        verbose_name_plural = verbose_name
